#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

setupenvironment

buildpackage 'simple-package'
buildpackage 'simple-package-update'

testpkgnotinstalled 'simple-package'
aptgetinstallpackage 'simple-package'
testpkginstalled 'simple-package'

testequal "$(builtpackageversion 'simple-package')" getpackageversion 'simple-package'

generaterepository_and_switch_sources "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS"

testsuccess aptget update

testfailure aptget upgrade -y
testequal "$(builtpackageversion 'simple-package')" getpackageversion 'simple-package'

testsuccess aptget upgrade -y -o APT::Get::EnableUpgrade=true
testequal "$(builtpackageversion 'simple-package-update')" getpackageversion 'simple-package'
